package com.company;

/**
 * @author : cyw
 * @date : created in  下午5:51 2021/6/11
 * @description :
 * @modified by :
 * @Version : $
 */

import com.company.command.ICommand;
import com.company.constant.SysConstant;
import com.company.factory.CommandFactory;
import com.company.util.DataUtils;

import java.util.Scanner;

/**
 * 经过重构的代码
 */
public class Client {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int command = 1;
        DataUtils.showMenu();
        while (true){
            command = scanner.nextInt();
            ICommand iCommand = parsingCommand(command);
            if (iCommand == null){
                System.out.println("无效命令");
            }else {
                iCommand.command();
            }
        }
    }

    /**
     * 解析命令
     * @param command
     * @return
     */
    public static ICommand parsingCommand(int command){
        if (command == SysConstant.SHOW_PATH){
            return CommandFactory.getShowCurrentPathICommandInstance();
        }else if (command == SysConstant.SHOW_ALL_FILE){
            return  CommandFactory.getShowAllMemuICommandInstance();
        }else if (command == SysConstant.ENTER_PATH){
            return CommandFactory.getEnterInputPathCommandInstance();
        }
        return  null;
    }
}
